package com.neusoft.databus.sap.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.bizcore.web.dto.result.ResultListDTO;
import com.neusoft.databus.sap.service.ExMonitorDataService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 监控指标数据控制器
 *
 * @author naxiang
 */
@Api("监控指标数据扩展控制器")
@RestController
@ConditionalOnProperty(name = "databus.core.hbase.enabled", havingValue = "false", matchIfMissing = true)
@RequestMapping(value = {"/api/w/monitordatas/ex" })
public class ExMonitorDataController {

    @Autowired
    private ExMonitorDataService exMonitorDataService;

    /**
     * 查询监控指标实时数据
     *
     * @param resourceCode
     * @return
     */
    @ApiOperation("批量查询监控指标实时数据")
    @PostMapping("/realtime")
    public ResultListDTO<?> realtimeData(@RequestBody final List<String> resources) {
        final List<Map<String, Object>> result =
                this.exMonitorDataService.findInCache(resources);
        return ResultListDTO.success(result);
    }
}
